package com.wellgoon.test.util;

import com.google.gson.Gson;
import com.wellgoon.test.vo.LogVO;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

@Data
@Slf4j
public class LogTimeTask extends TimerTask {

    private LogVO logVO;

    public LogTimeTask() {
    }

    public LogTimeTask(LogVO logVO) {
        this.logVO = logVO;
    }

    @Override
    public void run() {
        log.info("log："+ new Gson().toJson(logVO));
        Class<LogTimeTask> logTimeTaskClass = LogTimeTask.class;
        logTimeTaskClass.getClass();
        try {
            Class.forName("com.wellgoon.test.TestApplication");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        ExecutorUtils.EXECUTOR_SERVICE.schedule(this,5, TimeUnit.SECONDS);
//        this.cancel();
    }//
}
